import PIL.Image
import pygame
def getDieZombieImages(imagePath: str, zombieName: str):
    im1 = PIL.Image.open(imagePath)
    angle = 5
    img_num = 0
    while angle<90:
        im2 = im1.rotate(angle)
        im2.save(f"img/ufo/dieToLeft/{img_num}.png")
        angle += 5
        img_num+=1

def getDieToRightUFOImages(imagePath: str):
    im1 = PIL.Image.open(imagePath)
    angle = -5
    img_num = 0
    while angle>-90:
        im2 = im1.rotate(angle)
        im2.save(f"img/ufo/dieToRight/{img_num}.png")
        angle -= 5
        img_num+=1

def getDieToLeftUFOImages(imagePath: str):
    im1 = PIL.Image.open(imagePath)
    angle = 5
    img_num = 0
    while angle < 90:
        im2 = im1.rotate(angle)
        im2.save(f"img/ufo/dieToLeft/{img_num}.png")
        angle += 5
        img_num+=1

def scale_image(image, scale_x, scale_y):
    image_width = image.get_width()
    image_height = image.get_height()
    return pygame.transform.smoothscale(image, (image_width * scale_x, image_height * scale_y))



def get_imagelist_from_horizontal_sheet(sheetpath, image_num, scale, color):
    result = []
    sheet = pygame.image.load(sheetpath)
    sheet_width = sheet.get_width()
    sheet_height = sheet.get_height()
    width = sheet_width / image_num
    height = sheet_height
    for i in range(image_num):
        image = pygame.Surface((width, height)).convert_alpha()
        image.blit(sheet, (0, 0), ((i * width), 0, width, height))
        image = pygame.transform.scale(image, (width * scale, height * scale)).convert_alpha()
        image.set_colorkey(color)
        result.append(image)

    return result